#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int K;
    cin>>K;
    while(K--){
        int n,m,L,V;
        int d[100000],v[100000],a[100000],p[100000];
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++) cin>>d[i]>>v[i]>>a[i];
        for(int i=0;i<n;i++) cin>>p[i];
        cout<<0<<m;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
